<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%String path = request.getContextPath() ;%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div>
<div id="pageInTab" class="pageInTab">
	<div tabid="tabA" lselected="true">
		<div class="searchArea">
			<!-- 搜索表单开始 -->
			<form id="searchBar">
				<div class="fieldset1 clearFix">
					<div class="FXBR">
						<div class="fieldBox">
			                <div class="label">机构名称</div>
			                <div class="field">
			                    <input name="fundRasInsNm"   type="text" class="ui-textbox"   ligerui="width: 140">
			                </div>
			            </div>
						<div class="fieldBox">
			                <div class="label">项目名称</div>
			                <div class="field">
			                    <input name="fncPrjNm"  type="text" class="ui-textbox"   ligerui="width: 140">
			                </div>
			            </div>
			            <div class="fieldBox">
			                <div class="label">流程编号</div>
			                <div class="field">
			                    <input name="flowNo"  type="text" class="ui-textbox"   ligerui="width: 140">
			                </div>
			            </div>
			            <div class="fieldBox">
			                <div class="label">还款类别</div>
			                <div class="field">
			                    <select id="rePyTpCd" name="rePyTpCd"  ligerui="width: 140">
			                        <option value="" seleted>请选择</option>
			                        	<option value="1">主动还款</option>
			                        	<option value="2">被动还款</option>
			                    </select>
			                </div>
			            </div>
			            <div class="fieldBox">
			                <div class="label">费用项</div>
			                <div class="field">
			                	<input id="feeCls" name="feeCls" type="text" class="ui-textbox" data-value=" " placeholder="--请选择--" ltype="combobox"  ligerui="width: 140">
			                </div>
			            </div>   

		            </div>
						<div class="fieldBox">
			                <div class="label">实际付款时间</div>
			                <div class="field">
			                   <input id="actPymtDtStart"   name="actPymtDtStart"  type="text" class="ui-datepicker"  /> 
			                   <span>—</span>
			                   <input id="actPymtDtEnd"  name="actPymtDtEnd"  type="text" class="ui-datepicker"  />
			                </div>
			            </div>
            
					</div>
					<div class="clearFix"></div>
					
					<!-- 表单按钮 -->
					<div class="btnsBox formBtns notRight">
						<span id="searchBtn" class="sq-button-round">查询</span>
						<span id="clearBtn" class="sq-button-round">清空</span>
						<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
						<span  class="sq-button-round" onclick="realPayExport();">导出</span>
		            </div>
		            
				</div>
			</form>
			<!-- 搜索表单结束 -->
		</div>
		<!-- 列表显示块 -->
		<div id="ligergrid1" class="sq-grid"></div>
	</div>
	
</div>
</div>
</div>
<script type="text/javascript">
	var pageInApp={
		flag:false //tab页验证关闭
	};//to下一级子窗口 接口
	var pageInTab=null;//页签
	var loadedTabs=[];//页签
	var grid = null;
	
	$(function () {
		//费用项
		$("#feeCls").ligerComboBox({ 
			url: '<%=path%>/rfbase/fncprjpaysch/feeList.do',
			ajaxType :'GET',
            slide: false,
            selectBoxHeight: 200,
            valueField: 'key', 
            textField: 'value',
            isMultiSelect: true
        });
		
		$("#searchBar").ligerForm();//初始化表单
		
	    initGrid();//初始化列表
	    searchBtnEvent();//查询按钮事件
	    clearBtnEvent();//清空按钮事件
	});
	
	
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
		var data = form.getData();
		return data;
	}
	
	//初始化列表
	function initGrid(){
		$("#ligergrid1").ligerGrid({
			url:'<%=path%>/rfbase/fncprjpaysch/realPayPageList.do',
			method:'get',
			parms:getSearchParams(),
			columns:[
				{ display: '机构名称', name: 'FUND_RAS_INS_NM',minWidth: 140},
				{ display: '项目名称', name: 'FNC_PRJ_NM',minWidth: 140},
				{ display: '项目编号', name: 'FNC_PRJ_ID',minWidth: 200},
				{ display: '还款类别', name: 'REPY_TP'},
				{ display: '费用项', name: 'FEE_CLS_CD'},
				{ display: '流程编号', name: 'P_NO',minWidth: 180,
					render: function (rowdata, rowindex, value, column) { 
            			if(StringUtils.isEmpty(value)){
            				return "";
                		}
            			var h='<a href="javascript:showFlow(';
                        h+="'"+rowindex+"'";
                        h+=')">'+value+'</a>';
                        return h;
            		}
				},
				{ display: '申请人', name: 'RL_NM'},
				{ display: '实际付款时间', name: 'ACT_PYMT_DT_'},
				{ display: '实际付款金额', name: 'ACT_PYMT_AMT_'},
				{ display: '实际付款帐号', name: 'ACC_NO',minWidth: 140},
				{ display: '实际收款帐户', name: 'BAN_ACC_NM',minWidth: 140},
				{ display: '实际收款帐号', name: 'RCV_ACC_NUM',minWidth: 140}
				
			],
			pageSize:20,
			root:'rows',
			record:'total',
			hideLoadButton:false,
			width:'100%',
			height:'100%',
			heightDiff:-2,
			//checkbox:true,//列表是否有选择框
			rownumbers:true,//列表是否有行号
			//选择行事件
			onSelectRow: function(rowdata, rowid, rowobj){
				
			},
			//取消选择行事件
			onUnSelectRow : function(rowdata, rowid, rowobj){
				
			}
		});
		grid = liger.get("ligergrid1");
		grid.setHeight(100);
		//grid.options.isSingleCheck = true;//列表是否为单选
	}
	
	
	
	//清空按钮事件
	function clearBtnEvent(){
		$("#clearBtn").click(function(event) {
			$("#resetBtn").click();  //重置 input-text
			var form = liger.get("searchBar");
			form.setData({  //重置select等特殊表单
				"rePyTpCd":"",
				"feeCls":""
			});
			
		});
	}
	
	//查询按钮事件
	function searchBtnEvent(){
		$("#searchBtn").click(function(event) {
			var form = new liger.get("searchBar");
			var data = form.getData();
			//alert(JSON.stringify(data));
			for (name in data){
				grid.setParm(name,data[name]);
			};
			grid.reload();
		});
	}
	
	function showFlow(_index){
		
    	var _audStsCd = liger.get("ligergrid1").rows[_index].AUD_STS_CD;
    	var _pInstId = liger.get("ligergrid1").rows[_index].P_INST_ID;
    	var _dataId  = liger.get("ligergrid1").rows[_index].DATA_ID;
    	
    	if(StringUtils.isEmpty(_pInstId)){
			UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
			return;
		}
    	var _formUrl = "/rfbase/fncprjpaysch/toRepayModifyPage.do?fid=";
    
		var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_dataId+"&formUrl="+_formUrl;
		Add_navTab('tab_spl_bank_flow_'+_pInstId,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
    }
	

	//实际付款流水导出
	function realPayExport(){
		var form = liger.get("searchBar");
		var data = form.getData();
        
		var wait_dialog = null;
		$.ajax({
			type: 'post',
			dataType:'json',
			url: '<%=path%>/rfbase/fncprjpaysch/realPayExport.do',
			data:data,
			beforeSend:function(){
				wait_dialog=$.ligerDialog.SQalert({content: '正在导出...',SQ_type: "waitting"});
			},
			success:function(msg){
				wait_dialog.close();
				if(msg.success == 1){
					window.open(msg.data);
				}else{
					$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				}
			} 
		});
	}
	
	
</script>
</body>
</html>